﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:local="clr-namespace:NETXPF.WPF"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    
    <Style x:Key="{x:Type local:DockableControl}" TargetType="{x:Type local:DockableControl}">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type local:DockableControl}">
					<Border Background="{TemplateBinding Background}">
						<Grid Background="{TemplateBinding Background}">
							<Grid.RowDefinitions>
								<RowDefinition Height="20"/>
								<RowDefinition Height="*"/>
							</Grid.RowDefinitions>
							
							<!-- Header of the control-->
							<Grid Grid.Row="0" 
								local:DockableContainer.ElementForDragging="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:DockableControl}}}">
								<Grid.ColumnDefinitions>
									<ColumnDefinition />
									<ColumnDefinition Width="20"/>
								</Grid.ColumnDefinitions>
								
								<Border>
									<ContentPresenter Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}"/>
								</Border>
							
								<Button Command="local:DockableContainer.ToggleDockChild" 
									CommandParameter="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:DockableControl}}}" 
									Grid.Column="1" >
									<Button.Template>
										<ControlTemplate TargetType="Button">
											<Grid>
												<Grid.RowDefinitions>
													<RowDefinition Height="2*"/>
													<RowDefinition Height="8*"/>
												</Grid.RowDefinitions>
												<Grid.ColumnDefinitions>
													<ColumnDefinition Width="8*"/>
													<ColumnDefinition Width="2*"/>
												</Grid.ColumnDefinitions>
												
												<Path Data="M 181,34  L  180,71 L 217,71 L 217,35 L 181,34" 
													Fill="Silver" Stroke="Gray" Stretch="Fill" Grid.Row="1" Grid.Column="0" />
													
													<Path Data="M 256,180  L  289,145 L 274,129 L 328,119 L 319,166 L 305,156 L 271,192 L 256,180" 
													Fill="Silver" Stroke="Gray" Stretch="Fill" Grid.RowSpan="2" Grid.ColumnSpan="2"/>
												
											</Grid>
										</ControlTemplate>
									</Button.Template>
								</Button>
							</Grid>
							
							<Border Grid.Row="1">
								<ContentPresenter Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
							</Border>
							
						</Grid>
					</Border>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
    </Style>
    
    
    <Style x:Key="{x:Type local:DockableContainer}" TargetType="{x:Type local:DockableContainer}">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type local:DockableContainer}">
					
					<Canvas Name="PART_DraggingSurface" Grid.RowSpan="3" Grid.ColumnSpan="3" Background="{TemplateBinding Background}">
					
						<DockPanel Name="PART_Top" Canvas.Top="0" 
							Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type Canvas}}, Path=ActualWidth}"/>
							
						<DockPanel Name="PART_Left" Canvas.Left="0" 
							Canvas.Bottom="{Binding ElementName=PART_Bottom, Path=ActualHeight}"
							Height="{TemplateBinding SidePanelHeight}"/>
							
						<DockPanel Name="PART_Right" Canvas.Right="0" 
							Canvas.Bottom="{Binding ElementName=PART_Bottom, Path=ActualHeight}"
							Height="{TemplateBinding SidePanelHeight}" />
						
						<DockPanel Name="PART_Body" 
							Canvas.Left="{Binding ElementName=PART_Left, Path=ActualWidth}" 
							Canvas.Top="{Binding ElementName=PART_Top, Path=ActualHeight}"
							Height="{TemplateBinding SidePanelHeight}"
							Width="{TemplateBinding SidePanelWidth}"/>
						
						<DockPanel Name="PART_Bottom" Canvas.Bottom="0"
							Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type Canvas}}, Path=ActualWidth}"/>
					
					</Canvas>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
    </Style>
    
</ResourceDictionary>